Array.prototype.lFind = function (callback, thisArg) {
  if (typeof callback !== 'function') {
    throw new TypeError(`${callback} must be a function`);
  }

  const array = this;
  let target = null;
  for (let i = 0; i < array.length; i++) {
    if (array.hasOwnProperty(i)) {
      const flag = callback.call(thisArg, array[i], i, array);
      if (flag) {
        target = array[i];
        return target;
      }
    }
  }
  return undefined;
};

const target = [1, 2, 3, 4].lFind((x) => x > 2);
console.log(target);

const calculator = {
  base: 2,
  selectFirstOne: function (numbers) {
    return numbers.lFind((item) => item % this.base === 0, this);
  },
};

console.log(calculator.selectFirstOne([1, 3, 5, 9, 7, 8, 34]));
